/**
 * 
 */
package com.laozhao.wintersystem;

import org.w3c.dom.Node;

/**
 * @author zdongmen
 *
 */
public abstract class AbstractNode<T> implements BaseNode<T> {

	private T clazz;
	
	private String id;
	private String name;
	private String icon;
	private String description;

	/* (non-Javadoc)
	 * @see com.laozhao.wintersystem.BaseNode#getId()
	 */
	@Override
	public String getId() {
		return id;
	}

	/* (non-Javadoc)
	 * @see com.laozhao.wintersystem.BaseNode#setId(java.lang.String)
	 */
	@Override
	public void setId(String id) {
		if (id != null && "".equals(id)) {
			this.id = id;
		}
	}
	
	/* (non-Javadoc)
	 * @see com.laozhao.wintersystem.BaseNode#getClassName()
	 */
	@Override
	public String getName() {
		return name;
	}

	/* (non-Javadoc)
	 * @see com.laozhao.wintersystem.BaseNode#setName(java.lang.String)
	 */
	@Override
	public void setName(String name) {
		if (name != null && "".equals(name)) {
			this.name = name;
		}
	}

	/* (non-Javadoc)
	 * @see com.laozhao.wintersystem.BaseNode#getIcon()
	 */
	@Override
	public String getIcon() {
		return icon;
	}
	
	/* (non-Javadoc)
	 * @see com.laozhao.wintersystem.BaseNode#setIcon(java.lang.String)
	 */
	@Override
	public void setIcon(String icon){
		if (icon != null && "".equals(icon)) {
			this.icon = icon;
		}
	}

	/* (non-Javadoc)
	 * @see com.laozhao.wintersystem.BaseNode#getDescription()
	 */
	@Override
	public String getDescription() {
		return description;
	}

	/* (non-Javadoc)
	 * @see com.laozhao.wintersystem.BaseNode#setDescription(java.lang.String)
	 */
	@Override
	public void setDescription(String description) {
		if (description != null && "".equals(description)) {
			this.description = description;
		}
	}

//	/* (non-Javadoc)
//	 * @see com.laozhao.wintersystem.BaseNode#getProperty(java.lang.String)
//	 */
//	@Override
//	public Property getProperty(String name) {
//		return null;
//	}
//
//	/* (non-Javadoc)
//	 * @see com.laozhao.wintersystem.BaseNode#setProperty(com.laozhao.wintersystem.Property)
//	 */
//	@Override
//	public void setProperty(Property value) {
//		// TODO Auto-generated method stub
//
//	}


	/* (non-Javadoc)
	 * @see com.laozhao.wintersystem.BaseNode#load(org.w3c.dom.Node)
	 */
	@Override
	public void load(Node node) {
		setId(WSTools.getStringAttribute(node, BaseNode.ATTRIBUTE_ID));
		setName(WSTools.getStringAttribute(node, BaseNode.ATTRIBUTE_NAME));
		setIcon(WSTools.getStringAttribute(node, BaseNode.ATTRIBUTE_ICON));
		setDescription(WSTools.getStringAttribute(node, BaseNode.ATTRIBUTE_DESCRIPTION));
	}
	
	public void setClassName(String name){
		try {
			clazz = (T) Class.forName(name);
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public T getClassObject(){
		
		return null;
		
	}
}
